package cn.oowoo.rabbitmqclient2001.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: BinZhang
 * @Date: 2018/10/30 13:00
 * @Description:创建监听类，需要spring实例化
 * 
 */

@Component
public class ConsumerListener{
        //直连交换机测试 （可以多个队列绑定同一个直连交换机，类似于广播交换机，他们的区别是：广播交换机没有routingkey，直连交换机需要指定一个routingkey）
        @RabbitListener(queues = "FIRST_QUEUE")
        public void firstQueuepProcess(String msg) {
            System.out.println("队列 FIRST_QUEUE 收到消息：" + msg);
        }
        @RabbitListener(queues = "FIVE_QUEUE")
        public void fiveQueuepProcess(String msg) {
            System.out.println("队列 FIVE_QUEUE 收到消息：" + msg);
        }


        //主题交换机，使用通配符模糊匹配routingkey
        @RabbitListener(queues = "SECOND_QUEUE")
        public void secondQueuepProcess(String msg){
            System.out.println("队列 SECOND_QUEUE 收到消息："+msg);
        }


        //THIRD_QUEUE,FOURTH_QUEUE 广播交换机（扇形），一个交换机多个队列收消息
        @RabbitListener(queues = "THIRD_QUEUE")
        public void thirdQueuepProcess(String msg){
            System.out.println("队列 THIRD_QUEUE 收到消息："+msg);
        }
        @RabbitListener(queues = "FOURTH_QUEUE")
        public void fourthQueuepProcess(String msg){
            System.out.println("队列 FOURTH_QUEUE 收到消息："+msg);
        }

}
